<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script>
			function showtime(){
				var today = new Date();
			    var year=today.getFullYear();
				var month=today.getMonth();
				var day=today.getDate();
				var hour=today.getHours();
				var min=today.getMinutes();
				var sec=today.getSeconds();
				document.getElementById("demo").innerHTML="当前时间:"+year+"-"+(month+1)+"-"+day+"   "
				+hour+":"+min+":"+sec;	
			}
			//settimeout setInterval 
			var mytime=setInterval("showtime()",1000);
			//间隔多长时间执行一次，单位是ms，可以自己重复执行
			function controltime(){
				var cc=document.getElementsByTagName("input")[0];
				if(cc.value="暂停"){
					clearInterval(mytime);//时间就停止
					cc.value="启动";
				}
				else if(cc.value="启动"){
					mytime=setInterval("showtime()",1000);
					cc.value="暂停";
				}
			}			
		</script>
	</head>
	<body>
		<p id="demo"></p>
		<!-- 4： 实现时间的显示功能，(Date)
		要求能显示星期几，年月日，小时分钟秒 -->
		<input type="button" value="暂停" onclick="controltime()">
		
	</body>
</html>